package yifeng;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Properties;
import java.util.Set;


/**
 * 1801
 * @author pengyifeng
 *
 */
public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws FileNotFoundException 
	 */
	public static void main(String[] args) throws FileNotFoundException, IOException {
		Properties p = new Properties();
		p.load(new FileInputStream(Main.class.getResource("").getPath() + "/fffff"));
		
		int scores = 0;
		LinkedHashMap<String, Integer> map = new LinkedHashMap<String, Integer>();
		for(String key : p.stringPropertyNames()){
			int sum = sumup(p.getProperty(key));
			System.out.println(key + ": " + sum);
			scores +=sum;
			map.put(key, sum);
		}
		
		
		Set<String> set = map.keySet();
		Iterator<String> itr = set.iterator();
		String resultString = "";
		for(int i = 0; i < set.size(); i++){
			String k = itr.next();
			resultString += k;
			resultString += (":" + map.get(k) + " + ");
		}
		resultString = resultString.substring(0, resultString.length() - 2);
		resultString += ("= " + scores);
		System.out.println(resultString);
		                                               
	}

	private static int sumup(String property) {
		String[] t = property.split("\\+"); 
		int sum = 0;
		for(String s : t)
			sum += Integer.valueOf(s);
		return sum;
	}

}
